#!/usr/bin/env python
# -*- encoding: utf-8 -*-
'''
@File    :   myopiamodel.py
@Time    :   2020/06/21 14:03:40
@Author  :   caotian6666 
@Version :   1.0
@Contact :   caotiandyx@163.com
@License :   (C)Copyright 2017-2018, Liugroup-NLPR-CASIA
@Desc    :   None
'''

# here put the import lib

import os
import sys
curpath=os.path.abspath(os.curdir)
sys.path.append(curpath)
import lenetmyopiadataloader as lmd

import random
import paddle
import paddle.fluid as fluid
from paddle.fluid.dygraph.nn import Conv2D,Pool2D,Linear
import numpy as np
class LeNet(fluid.dygraph.Layer):
    def __init__(self,num_classes=1):
        super(LeNet,self).__init__()

        self.conv1=Conv2D(num_channels=3,num_filters=6,filter_size=5,act='sigmoid')
        self.pool1=Pool2D(pool_size=2,pool_stride=2,pool_type='max')
        self.conv2=Conv2D(num_channels=6,num_filters=16,filter_size=5,act='sigmoid')
        self.pool2=Pool2D(pool_size=2,pool_stride=2,pool_type='max')
        self.conv3=Conv2D(num_channels=16,num_filters=120,filter_size=4,act='sigmoid')
        self.fc1=Linear(input_dim=300000,output_dim=64,act='sigmoid')
        self.fc2=Linear(input_dim=64,output_dim=num_classes)
    def forward(self,x):
        x=self.conv1(x)
        x=self.pool1(x)
        x=self.conv2(x)
        x=self.pool2(x)
        x=self.conv3(x)
        x=fluid.layers.reshape(x,[x.shape[0],-1])
        x=self.fc1(x)
        x=self.fc2(x)
        return x
